<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>admin/js/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath %>admin/test/css/icon.css">
	<script type="text/javascript" src="<%=basePath %>admin/test/js/jquery-1.3.2.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>admin/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>admin/js/easyui-lang-zh_CN.js"></script>

		<!-- jquery 特效 -->
<link rel="stylesheet" type="text/css" href="<%=basePath %>admin/test/css/easyui.css"/>
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>admin/flexigrid/css/flexigrid_gray.css">
		<link rel="stylesheet" type="text/css"
			href="<%=basePath%>admin/flexigrid/jqModal/css/jqModal_gray.css">

	

	<script>
		$(function(){
			$('#test').datagrid({
				title:'患者预约信息一览表',
				iconCls:'icon-ok',
				width:1000,
				height:650,
				pageNumber:1,
				pageSize:15,
				pageList:[5,10,15,20,25,30,35,50,80,100],
                collapsible:true,
				nowrap: false,
				striped: true,
				url:'<%=basePath%>detailStateuserAction',
				sortName: 'id',
				sortOrder:'desc',
				rownumbers:true,
				idField:'id',
				queryParam:{},
				singleSelect:false,
				frozenColumns:[[
                 {field:'ck',checkbox:false}
              ]],
	        columns:[[
	      {field:'id',title:'编号',width:150,sortable:true,editor:'text'},
		  {field:'uuser',title:'患者姓名',width:150,sortable:true,editor:'text'},
		  {field:'zhuanjia',title:'就诊医生',width:150,sortable:true,editor:'text'},
		  {field:'yytime',title:'会诊时间',width:150,sortable:true,editor:'text'},
		  {field:'ordertime',title:'预约时间',width:150,sortable:true,editor:'text'},
		  {field:'state',title:'就诊状态',width:100,editor:'text'},
		 {field:'oper',title:'修改状态',width:100,
          formatter:function(value,row,index){
        if(row.state=='已就诊')
        {
            var s ='<label style="text-decoration: none;color: green;">已就诊</label>  ';
            return s;
          
        }
        if(row.state=='黑名单')
        {
           var b ='<a href="javascript:void(0);" onclick="saveRow('+row.id+',3)" style="text-decoration: none;color: #800080;">取消黑名单</a>  ';
           return b;
        }
       if(row.state=='退号')
        {
           var a ='<label  style="text-decoration: none;color: #800080;">已退号</label>  ';
           return a;
        }
        if(row.state=='已交费')
        {
          var m ='<label style="text-decoration: none;color: green;">已交费</label>  ';
         return m;
        }
         if(row.state=='违约')
        {
          var n ='<label style="text-decoration: none;color: green;">违约</label>  ';
         return n;
        }
        else
        {
            var e ='<a href="javascript:void(0);" onclick="saveRow('+row.id+',1)" style="text-decoration: none;color: blue;">就诊</a>  ';
            return e;
        }}}
				]],
				pagination:true,//分页时需要设置,下方显示分页插件
				rownumbers:true
			});
		});
		
	</script>
	<script>
	function saveRow(id,state)
	{
	   	$.ajax({
				   type: 'post',
				   url: "updateStateyuyueAction",
				   data: "info="+id+"\t"+state,
				   success: function(data)
				   {
			    		if(data=='ok')
			    		{
			    			$.messager.alert('后台提示', '交费成功', 'info');
			    			//初始化
			    			$('#add').dialog('close');
			    			$('#test').datagrid('reload');
			    		}
						if(data.split("\t")[0]=='money')
						{
						  
						  $.messager.confirm('确认交钱','请交挂号费'+data.split("\t")[1]+"元挂号费",function(r)
							{
							   if (r)
							   {
							    	saveRow(id,4);
							   }	
							   else
							   {
							     saveRow(id,5);
							   }
					   		});
			    			//初始化
			    			        $('#test').datagrid('reload');
						}
						if(data=='error')
						{
			    			$.messager.alert('后台提示', '数据修改失败', 'info');
			    			$('#add').dialog('close');
			    		}
					}
					
				  });
	 
	}
	</script>
</head>
<body>
   <div style="padding-left: 160px;">
	<table id="test"></table>
	</div>
</body>
</html>